package sort;

public class QuickSort {
    public static void main(String[] args) {
        int[] intArray = {10, 23, 37, 45, 56, 61, 72, 84, 95, 2, 14, 28, 33, 49, 55, 67, 78, 89, 90, 1};
       //  quickSort(intArray,0,intArray.length-1);
        maopao(intArray);
        for (int i : intArray) {
            System.out.print(i+" ");
        }

    }
    private static void quickSort(int[] array, int left, int right) {
        int l = left;
        int r = right;
        if (left > right|| left < 0 || right >= array.length)
            return;
        while (l<r){
            while (l<r && array[r] >= array[left])
                r--;
            while (l<r &&  array[l] <= array[left])
                l++;
            int tmp = array[r];
            array[r] = array[l];
            array[l] = tmp;
        }

        int tmp = array[left];
        array[left] = array[l];
        array[l] = tmp;

        quickSort(array, left, l-1);
        quickSort(array, l+1, right);
    }
    static  void maopao(int[] array){
        for(int i = 0 ; i< array.length;i++)
            for(int j = i;j<array.length;j++)
            if (array[i] < array[j])
            {
                int tmp  = array[i];
                array[i] = array[j];
                array[j] = tmp;
            }

    }
}
